<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the TableProjectCancel class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single TableProjectCancel object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a TableProjectCancelMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 * 
	 * @package My Application
	 * @subpackage MetaControls
	 * property-read TableProjectCancel $TableProjectCancel the actual TableProjectCancel data class being edited
	 * property QLabel $IdControl
	 * property-read QLabel $IdLabel
	 * property QListBox $UserIdControl
	 * property-read QLabel $UserIdLabel
	 * property QListBox $ProjectIdControl
	 * property-read QLabel $ProjectIdLabel
	 * property QIntegerTextBox $ReasonTypeControl
	 * property-read QLabel $ReasonTypeLabel
	 * property QTextBox $CommentControl
	 * property-read QLabel $CommentLabel
	 * property QDateTimePicker $CancelDateControl
	 * property-read QLabel $CancelDateLabel
	 * property QTextBox $RequestByControl
	 * property-read QLabel $RequestByLabel
	 * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class TableProjectCancelMetaControlGen extends QBaseClass {
		// General Variables
		protected $objTableProjectCancel;
		protected $objParentObject;
		protected $strTitleVerb;
		protected $blnEditMode;

		// Controls that allow the editing of TableProjectCancel's individual data fields
		protected $lblId;
		protected $lstUser;
		protected $lstProject;
		protected $txtReasonType;
		protected $txtComment;
		protected $calCancelDate;
		protected $txtRequestBy;

		// Controls that allow the viewing of TableProjectCancel's individual data fields
		protected $lblUserId;
		protected $lblProjectId;
		protected $lblReasonType;
		protected $lblComment;
		protected $lblCancelDate;
		protected $lblRequestBy;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * TableProjectCancelMetaControl to edit a single TableProjectCancel object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single TableProjectCancel object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this TableProjectCancelMetaControl
		 * @param TableProjectCancel $objTableProjectCancel new or existing TableProjectCancel object
		 */
		 public function __construct($objParentObject, TableProjectCancel $objTableProjectCancel) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this TableProjectCancelMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked TableProjectCancel object
			$this->objTableProjectCancel = $objTableProjectCancel;

			// Figure out if we're Editing or Creating New
			if ($this->objTableProjectCancel->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
		 * edit, or if we are also allowed to create a new one, etc.
		 * 
		 * @param mixed $objParentObject QForm or QPanel which will be using this TableProjectCancelMetaControl
		 * @param integer $intId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing TableProjectCancel object creation - defaults to CreateOrEdit
 		 * @return TableProjectCancelMetaControl
		 */
		public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intId)) {
				$objTableProjectCancel = TableProjectCancel::Load($intId);

				// TableProjectCancel was found -- return it!
				if ($objTableProjectCancel)
					return new TableProjectCancelMetaControl($objParentObject, $objTableProjectCancel);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a TableProjectCancel object with PK arguments: ' . $intId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new TableProjectCancelMetaControl($objParentObject, new TableProjectCancel());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this TableProjectCancelMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing TableProjectCancel object creation - defaults to CreateOrEdit
		 * @return TableProjectCancelMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::PathInfo(0);
			return TableProjectCancelMetaControl::Create($objParentObject, $intId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this TableProjectCancelMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing TableProjectCancel object creation - defaults to CreateOrEdit
		 * @return TableProjectCancelMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::QueryString('intId');
			return TableProjectCancelMetaControl::Create($objParentObject, $intId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QLabel lblId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblId_Create($strControlId = null) {
			$this->lblId = new QLabel($this->objParentObject, $strControlId);
			$this->lblId->Name = QApplication::Translate('Id');
			if ($this->blnEditMode)
				$this->lblId->Text = $this->objTableProjectCancel->Id;
			else
				$this->lblId->Text = 'N/A';
			return $this->lblId;
		}

		/**
		 * Create and setup QListBox lstUser
		 * @param string $strControlId optional ControlId to use
		 * @return QListBox
		 */
		public function lstUser_Create($strControlId = null) {
			$this->lstUser = new QListBox($this->objParentObject, $strControlId);
			$this->lstUser->Name = QApplication::Translate('User');
			$this->lstUser->Required = true;
			if (!$this->blnEditMode)
				$this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
			$objUserArray = TableUserProject::LoadAll();
			if ($objUserArray) foreach ($objUserArray as $objUser) {
				$objListItem = new QListItem($objUser->__toString(), $objUser->Id);
				if (($this->objTableProjectCancel->User) && ($this->objTableProjectCancel->User->Id == $objUser->Id))
					$objListItem->Selected = true;
				$this->lstUser->AddItem($objListItem);
			}
			return $this->lstUser;
		}

		/**
		 * Create and setup QLabel lblUserId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblUserId_Create($strControlId = null) {
			$this->lblUserId = new QLabel($this->objParentObject, $strControlId);
			$this->lblUserId->Name = QApplication::Translate('User');
			$this->lblUserId->Text = ($this->objTableProjectCancel->User) ? $this->objTableProjectCancel->User->__toString() : null;
			$this->lblUserId->Required = true;
			return $this->lblUserId;
		}

		/**
		 * Create and setup QListBox lstProject
		 * @param string $strControlId optional ControlId to use
		 * @return QListBox
		 */
		public function lstProject_Create($strControlId = null) {
			$this->lstProject = new QListBox($this->objParentObject, $strControlId);
			$this->lstProject->Name = QApplication::Translate('Project');
			$this->lstProject->Required = true;
			if (!$this->blnEditMode)
				$this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
			$objProjectArray = TableProject::LoadAll();
			if ($objProjectArray) foreach ($objProjectArray as $objProject) {
				$objListItem = new QListItem($objProject->__toString(), $objProject->Id);
				if (($this->objTableProjectCancel->Project) && ($this->objTableProjectCancel->Project->Id == $objProject->Id))
					$objListItem->Selected = true;
				$this->lstProject->AddItem($objListItem);
			}
			return $this->lstProject;
		}

		/**
		 * Create and setup QLabel lblProjectId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblProjectId_Create($strControlId = null) {
			$this->lblProjectId = new QLabel($this->objParentObject, $strControlId);
			$this->lblProjectId->Name = QApplication::Translate('Project');
			$this->lblProjectId->Text = ($this->objTableProjectCancel->Project) ? $this->objTableProjectCancel->Project->__toString() : null;
			$this->lblProjectId->Required = true;
			return $this->lblProjectId;
		}

		/**
		 * Create and setup QIntegerTextBox txtReasonType
		 * @param string $strControlId optional ControlId to use
		 * @return QIntegerTextBox
		 */
		public function txtReasonType_Create($strControlId = null) {
			$this->txtReasonType = new QIntegerTextBox($this->objParentObject, $strControlId);
			$this->txtReasonType->Name = QApplication::Translate('Reason Type');
			$this->txtReasonType->Text = $this->objTableProjectCancel->ReasonType;
			return $this->txtReasonType;
		}

		/**
		 * Create and setup QLabel lblReasonType
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblReasonType_Create($strControlId = null, $strFormat = null) {
			$this->lblReasonType = new QLabel($this->objParentObject, $strControlId);
			$this->lblReasonType->Name = QApplication::Translate('Reason Type');
			$this->lblReasonType->Text = $this->objTableProjectCancel->ReasonType;
			$this->lblReasonType->Format = $strFormat;
			return $this->lblReasonType;
		}

		/**
		 * Create and setup QTextBox txtComment
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtComment_Create($strControlId = null) {
			$this->txtComment = new QTextBox($this->objParentObject, $strControlId);
			$this->txtComment->Name = QApplication::Translate('Comment');
			$this->txtComment->Text = $this->objTableProjectCancel->Comment;
			$this->txtComment->TextMode = QTextMode::MultiLine;
			return $this->txtComment;
		}

		/**
		 * Create and setup QLabel lblComment
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblComment_Create($strControlId = null) {
			$this->lblComment = new QLabel($this->objParentObject, $strControlId);
			$this->lblComment->Name = QApplication::Translate('Comment');
			$this->lblComment->Text = $this->objTableProjectCancel->Comment;
			return $this->lblComment;
		}

		/**
		 * Create and setup QDateTimePicker calCancelDate
		 * @param string $strControlId optional ControlId to use
		 * @return QDateTimePicker
		 */
		public function calCancelDate_Create($strControlId = null) {
			$this->calCancelDate = new QDateTimePicker($this->objParentObject, $strControlId);
			$this->calCancelDate->Name = QApplication::Translate('Cancel Date');
			$this->calCancelDate->DateTime = $this->objTableProjectCancel->CancelDate;
			$this->calCancelDate->DateTimePickerType = QDateTimePickerType::DateTime;
			return $this->calCancelDate;
		}

		/**
		 * Create and setup QLabel lblCancelDate
		 * @param string $strControlId optional ControlId to use
		 * @param string $strDateTimeFormat optional DateTimeFormat to use
		 * @return QLabel
		 */
		public function lblCancelDate_Create($strControlId = null, $strDateTimeFormat = null) {
			$this->lblCancelDate = new QLabel($this->objParentObject, $strControlId);
			$this->lblCancelDate->Name = QApplication::Translate('Cancel Date');
			$this->strCancelDateDateTimeFormat = $strDateTimeFormat;
			$this->lblCancelDate->Text = sprintf($this->objTableProjectCancel->CancelDate) ? $this->objTableProjectCancel->CancelDate->__toString($this->strCancelDateDateTimeFormat) : null;
			return $this->lblCancelDate;
		}

		protected $strCancelDateDateTimeFormat;


		/**
		 * Create and setup QTextBox txtRequestBy
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtRequestBy_Create($strControlId = null) {
			$this->txtRequestBy = new QTextBox($this->objParentObject, $strControlId);
			$this->txtRequestBy->Name = QApplication::Translate('Request By');
			$this->txtRequestBy->Text = $this->objTableProjectCancel->RequestBy;
			$this->txtRequestBy->MaxLength = TableProjectCancel::RequestByMaxLength;
			return $this->txtRequestBy;
		}

		/**
		 * Create and setup QLabel lblRequestBy
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblRequestBy_Create($strControlId = null) {
			$this->lblRequestBy = new QLabel($this->objParentObject, $strControlId);
			$this->lblRequestBy->Name = QApplication::Translate('Request By');
			$this->lblRequestBy->Text = $this->objTableProjectCancel->RequestBy;
			return $this->lblRequestBy;
		}



		/**
		 * Refresh this MetaControl with Data from the local TableProjectCancel object.
		 * @param boolean $blnReload reload TableProjectCancel from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objTableProjectCancel->Reload();

			if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objTableProjectCancel->Id;

			if ($this->lstUser) {
					$this->lstUser->RemoveAllItems();
				if (!$this->blnEditMode)
					$this->lstUser->AddItem(QApplication::Translate('- Select One -'), null);
				$objUserArray = TableUserProject::LoadAll();
				if ($objUserArray) foreach ($objUserArray as $objUser) {
					$objListItem = new QListItem($objUser->__toString(), $objUser->Id);
					if (($this->objTableProjectCancel->User) && ($this->objTableProjectCancel->User->Id == $objUser->Id))
						$objListItem->Selected = true;
					$this->lstUser->AddItem($objListItem);
				}
			}
			if ($this->lblUserId) $this->lblUserId->Text = ($this->objTableProjectCancel->User) ? $this->objTableProjectCancel->User->__toString() : null;

			if ($this->lstProject) {
					$this->lstProject->RemoveAllItems();
				if (!$this->blnEditMode)
					$this->lstProject->AddItem(QApplication::Translate('- Select One -'), null);
				$objProjectArray = TableProject::LoadAll();
				if ($objProjectArray) foreach ($objProjectArray as $objProject) {
					$objListItem = new QListItem($objProject->__toString(), $objProject->Id);
					if (($this->objTableProjectCancel->Project) && ($this->objTableProjectCancel->Project->Id == $objProject->Id))
						$objListItem->Selected = true;
					$this->lstProject->AddItem($objListItem);
				}
			}
			if ($this->lblProjectId) $this->lblProjectId->Text = ($this->objTableProjectCancel->Project) ? $this->objTableProjectCancel->Project->__toString() : null;

			if ($this->txtReasonType) $this->txtReasonType->Text = $this->objTableProjectCancel->ReasonType;
			if ($this->lblReasonType) $this->lblReasonType->Text = $this->objTableProjectCancel->ReasonType;

			if ($this->txtComment) $this->txtComment->Text = $this->objTableProjectCancel->Comment;
			if ($this->lblComment) $this->lblComment->Text = $this->objTableProjectCancel->Comment;

			if ($this->calCancelDate) $this->calCancelDate->DateTime = $this->objTableProjectCancel->CancelDate;
			if ($this->lblCancelDate) $this->lblCancelDate->Text = sprintf($this->objTableProjectCancel->CancelDate) ? $this->objTableProjectCancel->CancelDate->__toString($this->strCancelDateDateTimeFormat) : null;

			if ($this->txtRequestBy) $this->txtRequestBy->Text = $this->objTableProjectCancel->RequestBy;
			if ($this->lblRequestBy) $this->lblRequestBy->Text = $this->objTableProjectCancel->RequestBy;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC TABLEPROJECTCANCEL OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's TableProjectCancel instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveTableProjectCancel() {
			try {
				// Update any fields for controls that have been created
				if ($this->lstUser) $this->objTableProjectCancel->UserId = $this->lstUser->SelectedValue;
				if ($this->lstProject) $this->objTableProjectCancel->ProjectId = $this->lstProject->SelectedValue;
				if ($this->txtReasonType) $this->objTableProjectCancel->ReasonType = $this->txtReasonType->Text;
				if ($this->txtComment) $this->objTableProjectCancel->Comment = $this->txtComment->Text;
				if ($this->calCancelDate) $this->objTableProjectCancel->CancelDate = $this->calCancelDate->DateTime;
				if ($this->txtRequestBy) $this->objTableProjectCancel->RequestBy = $this->txtRequestBy->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the TableProjectCancel object
				$this->objTableProjectCancel->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's TableProjectCancel instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteTableProjectCancel() {
			$this->objTableProjectCancel->Delete();
		}		



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'TableProjectCancel': return $this->objTableProjectCancel;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to TableProjectCancel fields -- will be created dynamically if not yet created
				case 'IdControl':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'IdLabel':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'UserIdControl':
					if (!$this->lstUser) return $this->lstUser_Create();
					return $this->lstUser;
				case 'UserIdLabel':
					if (!$this->lblUserId) return $this->lblUserId_Create();
					return $this->lblUserId;
				case 'ProjectIdControl':
					if (!$this->lstProject) return $this->lstProject_Create();
					return $this->lstProject;
				case 'ProjectIdLabel':
					if (!$this->lblProjectId) return $this->lblProjectId_Create();
					return $this->lblProjectId;
				case 'ReasonTypeControl':
					if (!$this->txtReasonType) return $this->txtReasonType_Create();
					return $this->txtReasonType;
				case 'ReasonTypeLabel':
					if (!$this->lblReasonType) return $this->lblReasonType_Create();
					return $this->lblReasonType;
				case 'CommentControl':
					if (!$this->txtComment) return $this->txtComment_Create();
					return $this->txtComment;
				case 'CommentLabel':
					if (!$this->lblComment) return $this->lblComment_Create();
					return $this->lblComment;
				case 'CancelDateControl':
					if (!$this->calCancelDate) return $this->calCancelDate_Create();
					return $this->calCancelDate;
				case 'CancelDateLabel':
					if (!$this->lblCancelDate) return $this->lblCancelDate_Create();
					return $this->lblCancelDate;
				case 'RequestByControl':
					if (!$this->txtRequestBy) return $this->txtRequestBy_Create();
					return $this->txtRequestBy;
				case 'RequestByLabel':
					if (!$this->lblRequestBy) return $this->lblRequestBy_Create();
					return $this->lblRequestBy;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to TableProjectCancel fields
					case 'IdControl':
						return ($this->lblId = QType::Cast($mixValue, 'QControl'));
					case 'UserIdControl':
						return ($this->lstUser = QType::Cast($mixValue, 'QControl'));
					case 'ProjectIdControl':
						return ($this->lstProject = QType::Cast($mixValue, 'QControl'));
					case 'ReasonTypeControl':
						return ($this->txtReasonType = QType::Cast($mixValue, 'QControl'));
					case 'CommentControl':
						return ($this->txtComment = QType::Cast($mixValue, 'QControl'));
					case 'CancelDateControl':
						return ($this->calCancelDate = QType::Cast($mixValue, 'QControl'));
					case 'RequestByControl':
						return ($this->txtRequestBy = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>